#ifndef _SMART_DEVICE_MANAGER_HEAD_H
#define _SMART_DEVICE_MANAGER_HEAD_H
#include <stdio.h>
#include <iostream>
#include <stdint.h>
#include "smart-device-protocol.h"
#include "linux-uart.h"

class SmartDeviceManager
{
public:
    enum
    {
        SmartDeviceOpen = 0x00,
        SmartDeviceClose = 0x01,
        SmartDeviceQuery = 0x02
    };
    SmartDeviceManager(const string &uartDevice);
    bool sendPacket(const vector<uint8_t> &packet);

    bool recvPacket(vector<uint8_t> &packet);
    bool communication(SmartDeviceProtocol &protocol, vector<uint8_t> &ackData);

    //------------门锁------------
    bool openDoorlLock(uint8_t deviceType, uint8_t deviceNumber);
    bool closeDoorlLock(uint8_t deviceType, uint8_t deviceNumber);
    bool queryDoorlLock(uint8_t deviceType, uint8_t deviceNumber, uint8_t &lock_state);

    //----------电器--------------
    bool openElectrical(uint8_t deviceType, uint8_t deviceNumber);
    bool closeElectrical(uint8_t deviceType, uint8_t deviceNumber);
    bool queryElectrical(uint8_t deviceType, uint8_t deviceNumber, uint8_t &lockStatus);

    //--------------传感器--------------------
    bool querySensor(uint8_t deviceType, uint8_t deviceNumber, uint16_t &data);

    //--------------嗅探设备-----------------
    // 设备地址(4byte) + 设备类型(2byte) + 设备编号(1byte)
    bool sniffingDevice(uint8_t deviceType, uint8_t deviceNumber, vector<uint8_t> &info);

private:
    LinuxUart linuxUart;
};

#endif